package code.google.controller.search;

import code.google.controller.interfaces.ISearchController;
import code.google.gui.fragments.adapter.SearchResultAdapter;
import code.google.gui.interfaces.ISearchFragment;
import code.google.model.local.LocalClient;
import code.google.model.util.ModelProvider;

public class LocalSearchController implements ISearchController {

//	private static LocalSearchController instance;
	private ISearchFragment fragment;
	private LocalClient client;
	boolean isPlaying = false;
	
	public LocalSearchController(ISearchFragment fragment){
		client = ModelProvider.getInstance().getLocalClient();
		this.fragment = fragment;
	}
	
	@Override
	public void doSearch(String query) {
		client.scanStorage(fragment.getContext());
		if(client != null)
			fragment.setSearchResultAdapter(new SearchResultAdapter(client.doSearch(query), fragment));
	}
}
